using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using ShootThemUp.Sources.ScreenManagement;
using ShootThemUp.Sources.AudioElements;

namespace ShootThemUp.Sources.Screens
{
    class TitleScreen : GameScreen
    {
        private const int TITLE_SCREEN_DURATION = 4000; //ms
        private int currentTime = TitleScreen.TITLE_SCREEN_DURATION;
        private bool soundPlayed = false;

        public override void Update(Microsoft.Xna.Framework.GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            currentTime -= gameTime.ElapsedGameTime.Milliseconds;

            if (currentTime < 2500 && !soundPlayed)
            {
                Audio audio = Audio.GetInstance;
                soundPlayed = true;
                audio.PineApple.Play(1f,0f,0f);
            }

            if (currentTime < 0)
            {                
                LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(@"Menus\Textures2D\backgroundMenu"),
                                                           new MainMenuScreen(GameStateManagement.APP_NAME));

            }

            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }
    }
}
